﻿using System;
using System.Web.UI;
using Ria.Web.Controls;
using Ria.Infrastructure;

namespace Ria.Presentation.Web
{
    public partial class NoStates : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                fcControlOne.InitialData = DemoDataServices.GetControlOneInitialData();
        }

        protected void FcIncomingObject(object sender, IncomingObjectEventArgs e)
        {
            gtbLog.Text = string.Format("Selected -> name: {0} dob: {1} kids: {2}\n",
                            e.Data["name"],
                            DateTime.Parse(e.Data["dob"].ToString()).ToShortDateString(),
                            e.Data["kids"]) + gtbLog.Text;
        }

        protected void OnSayHello(object sender, EventArgs e)
        {
            gtbLog.Text = "AJAX button asked to say hello to [Simple Control]\n" + gtbLog.Text;
            fcControlOne.FlexCallObject(DemoDataServices.GetSayHello());
        }

        protected void OnAddRecord(object sender, EventArgs e)
        {
            gtbLog.Text = "AJAX button asked to add record to [Simple Control]\n" + gtbLog.Text;
            fcControlOne.FlexCallObject(DemoDataServices.GetOneRecord(0));
        }

        protected void OnClear(object sender, EventArgs e)
        {
            gtbLog.Text = "AJAX button asked to clear [Simple Control]\n" + gtbLog.Text;
            fcControlOne.FlexCallObject(DemoDataServices.GetClear());
        }
    }
}
